
import {Component} from 'react'
class SetState extends Component {
    state = {
        count: 0,
        name: 'hchlq',
        age: 18
    }
    render() {
        const {count} = this.state
        return <div>
            <button onClick={() => this.setState((state, props) => {
                console.log('state: ', state)
                console.log('newProps: ', props)
                return {...state, count: state.count + 1}
            })}>+1</button>
            <h1>{count}</h1>
        </div>
    }
}


let a = 1
class ForceState extends Component {
    render() {
        return <div>
            <button onClick={() => {
                a++
                this.forceUpdate()
            }}>+1</button>
            <h1>{a}</h1>
        </div>
    }
}
export {
    SetState,
    ForceState
}